home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-15 | 6.6 KB | 178 lines | [TEXT/MPS ] |
- ;
- ; File: DTS_SCSI_Driver.a
- ;
- ;
- ;
- ; Unfortunately, no matter how long awaited, it's still not done. In fact, this
- ; isn't even a release- this is just an image of the code taken in the middle of
- ; development.
- ;
- ; THIS CODE DOES NOT WORK AS A WHOLE. MUCH OF IT IS BUGGY AND / OR INCOMPLETE.
- ; YOU WOULD HAVE TO BE ABSOLUTELY INSANE TO USE ANY OF THIS CODE IN YOUR
- ; PROJECT WITHOUT EXTENSIVE THOUGHT, DEBUGGING AND TESTING.
- ;
- ;
- ;
- ;
- ; Contains: standard installation stubs, driver header, entry/exit points, and static data
- ;
- ; Written by: Craig Prouse
- ;
- ; Copyright: © 1992 by Apple Computer, Inc., all rights reserved.
- ;
- ; Change History (most recent first):
- ;
- ; <8> 04/24/92 tmd added BlockOffset to find start of Memory Mgr block;
- ; changed icon file variable to &iconFile
- ; <7> 11/25/91 chp remove ASYNC bit dependency from IOReturn2 to improve support
- ; for asynchronous drivers, explicitly return result in parameter
- ; block for immediate calls, and adjust padding
- ; <6> 10/25/91 chp use better (FORCEACTIVE) method for preventing dead-strip,
- ; documented in MPW 3.2 release notes
- ; <5> 10/17/91 chp modify so that installation code is not dead-stripped by the
- ; Link tool
- ; <4> 10/17/91 chp add support for SCSI driver installation procedure
- ; <3> 10/16/91 chp improve support for generating and including drive icon data at
- ; build time
- ; <2> 10/15/91 chp update header contents
- ; <1> 10/15/91 chp first checked in
- ;
- ; To Do:
- ;
- case on
- print push,off
- include 'SysEqu.a'
- print pop
-
- ; Our current driver version number, to be included in driver header.
- ; This must match the one in DTS_SCSI_Driver.h!
- DriverVersion equ 1
-
- ;
- ; Our main entry point. At boot time, the SCSI boot code loads this code into memory,
- ; locks it down, and JSRs to it. This code is responsible for installing the driver
- ; (which immediately follows this entry-point code).
- ;
- ; Note: This code must be loaded into a nonrelocateable (NewPtr) block in the
- ; system heap; the deallocation code in Install.c and in Application.c requires it!
- ;
- GInstall proc export, forceactive
- import InstallProc, OpenFunc, PrimeFunc, ControlFunc, StatusFunc, CloseFunc
-
- ;
- ; SCSI disk drivers are loaded at boot time and called to install themselves. The boot code in
- ; ROM passes some parameters in very strange places, making C implementations just a bit tricky.
- ; Here we move those parameters from their original registers, onto the stack for a C function
- ; with the following prototype:
- ;
- ; void InstallProc (Partition *partitionMap, long scsiID, Ptr sbData);
- ;
- move.l d7,-(sp) ; default data area (rarely used)
- move.l d5,-(sp) ; SCSI ID of device this driver came from
- move.l a0,-(sp) ; pointer to the drive's partition table
- bsr InstallProc
- lea 12(sp),sp
- rts
-
- DrvrStart proc export
- import OpenFunc, PrimeFunc, ControlFunc, StatusFunc, CloseFunc
- export DrvrHdr
-
- BlockOffset dc.l (DrvrHdr - GInstall) ; Distance to start of Memory Mgr block
- ; so we can find the pointer to unload
- ; it if we wish to dispose of the driver
-
- ; This is a standard 'DRVR' resource header
- ;
- DrvrHdr ; Actual start of driver for MacOS
- @drvrFlags dc.w $4F00 ; flags meaning "read, write, control, status, needsLock"
- @drvrDelay dc.w 0
- @drvrEvent dc.w 0
- @drvrMenu dc.w 0
- @drvrOpen dc.w GOpen - DrvrHdr
- @drvrPrime dc.w GPrime - DrvrHdr
- @drvrCtl dc.w GControl - DrvrHdr
- @drvrStatus dc.w GStatus - DrvrHdr
- @drvrClose dc.w GClose - DrvrHdr
- @drvrName dc.b '.DTS_SCSI' ; name must match the one in DTS_SCSI_Driver.h!
- drvrVers dc.b DriverVersion
- align 4
-
- ;
- ; Following are assembly language glue routines which call C language driver routine
- ; implementations and manage the driver return process through either a simple RTS
- ; or the JIODone vector, as appropriate. The required C functions are as indicated:
- ;
- ; OSErr OpenFunc (ParmBlkPtr pb, DCtlPtr dce);
- ; OSErr PrimeFunc (ParmBlkPtr pb, DCtlPtr dce);
- ; OSErr ControlFunc (ParmBlkPtr pb, DCtlPtr dce);
- ; OSErr StatusFunc (ParmBlkPtr pb, DCtlPtr dce);
- ; OSErr CloseFunc (ParmBlkPtr pb, DCtlPtr dce);
- ;
- GOpen move.b drvrVers,dCtlQueue+1(a1) ; register driver version number
- movem.l a0-a1,-(sp) ; save ParmBlkPtr, DCtlPtr across function call
- movem.l a0-a1,-(sp) ; push ParmBlkPtr, DCtlPtr for C
- bsr OpenFunc ; call linked C
- addq.l #8,sp ; clean up the stack
- movem.l (sp)+,a0-a1 ; restore ParmBlkPtr, DCtlPtr
- rts ; Open always uses synchronous RTS
-
- GPrime movem.l a0-a1,-(sp) ; save ParmBlkPtr, DCtlPtr across function call
- movem.l a0-a1,-(sp) ; push ParmBlkPtr, DCtlPtr for C
- bsr PrimeFunc ; call linked C
- addq.l #8,sp ; clean up the stack
- bra.s IOReturn
-
- GControl movem.l a0-a1,-(sp) ; save ParmBlkPtr, DCtlPtr across function call
- movem.l a0-a1,-(sp) ; push ParmBlkPtr, DCtlPtr for C
- bsr ControlFunc ; call linked C
- addq.l #8,sp ; clean up the stack
- movem.l (sp)+,a0-a1 ; restore ParmBlkPtr, DCtlPtr
- cmpi.w #killCode,csCode(a0) ; test for KillIO call (special case)
- bne.s IOReturn2
- rts ; KillIO must return via RTS
-
- GStatus movem.l a0-a1,-(sp) ; save ParmBlkPtr, DCtlPtr across function call
- movem.l a0-a1,-(sp) ; push ParmBlkPtr, DCtlPtr for C
- bsr StatusFunc ; call linked C
- addq.l #8,sp ; clean up the stack
-
- IOReturn movem.l (sp)+,a0-a1 ; restore ParmBlkPtr, DCtlPtr
- IOReturn2 move.w ioTrap(a0),d1
- btst #noQueueBit,d1 ; test IMMED bit
- beq.s @Queued ; IMMED calls not queued, so RTS
- move.w d0,ioResult(a0) ; with result explicitly in ioResult
- rts
-
- @Queued tst.w d0 ; test asynchronous return result
- bgt.s @RTS ; async I/O is incomplete if result > 0, so RTS
- @JIODone move.l (JIODone).w,-(sp) ; set up jIODone return vector
- @RTS rts
-
- GClose movem.l a0-a1,-(sp) ; save ParmBlkPtr, DCtlPtr across function call
- movem.l a0-a1,-(sp) ; push ParmBlkPtr, DCtlPtr for C
- bsr CloseFunc ; call linked C
- addq.l #8,sp ; clean up the stack
- movem.l (sp)+,a0-a1 ; restore ParmBlkPtr, DCtlPtr
- rts ; Close always synchronous RTS
-
- endmain
-
- DriveIcon proc export
-
- ; Data for the drive icon is generated from a resource file by a shell script at build
- ; time. The shell script creates an include file with a series of DC directives and the
- ; project build script passes in the name of the include file as a SET variable.
- ;
- ; &IconFile should be passed in as a command line option to the Asm tool, e.g.:
- ;
- ; Asm -define &IconFile="∂'DTS_SCSI.Icon.a∂'" DTS_SCSI.a
- ;
- include &IconFile
-
- WhereStr dc.b 'DTS SCSI Drive'
- align 4
-
- endproc
- end
-